package com.gagakuai.bpm.domian.events;


import com.gagakuai.bpm.common.aspect.MqBpmSender;
import com.gagakuai.bpm.domian.entity.BpmDeadMessageLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/*
 * @program: bpm_server
 * @description: 业务回调事件监听器
 * @author: houhong
 * @create: 2022-07-14 13:43
 */
@Slf4j
@Component
public class BusinessSysCallBackListener implements ApplicationListener<BusinessSysCallBackEvent> {

    @Autowired
    private MqBpmSender mqBpmSender;

    @Override
    public void onApplicationEvent(BusinessSysCallBackEvent businessSysCallBackEvent) {

        log.info("#============业务系统回调事件监听器=============#");

        BusinessSysCallBackEvent.BusinessSysCallBackEventData eventData = businessSysCallBackEvent.getEventData();
        BpmDeadMessageLog bpmDeadMessageLog = eventData.getBpmDeadMessageLog();
        //发布消息出去
        mqBpmSender.sendSystemCallBackMessage(bpmDeadMessageLog);
        log.info("#============业务系统发布成功=============#");
    }
}